<?php
//if(isset($_SESSION["IDGroup"]) && $_SESSION["IDGroup"]==0){
?>
	<div id="maincp">
	<h1 class="h1">Contact Manager</h1>
	<p>This table will show all contact list in database.</p>
	<table class="datatable">
			<thead>
                <tr>
                  <td>Customer Name</td>
                  <td>EMail</td>
                  <td>Contents</td>
                  <td>Date</td>
                </tr>
			</thead>
                <?php
                if (isset($_GET["page"])) {
                    $page  = $_GET["page"];
                }else{
                    $page=1;
                }
                $start = ($page-1) * 10;
					$feedback=ContactsList($start);
					while($row_feedback=mysql_fetch_array($feedback))
					{
						ob_start();
				?>
			<tbody>
                <tr>
                	<td>{Name}</td>
                	<td>{EMail}</td>
                	<td>{Contents}</td>
                    <td>{date}</td>
                </tr>
			</tbody>
                <?php
                $m=explode("-",$row_feedback["date_added"]);
				$date = $m[2]."/".$m[1]."/".$m[0];
				$s= ob_get_clean();
				$s=str_replace("{IDFeedBack}",$row_feedback["contacts_id"],$s);
				$s=str_replace("{date}",$date,$s);
				$s=str_replace("{Name}",$row_feedback["name"],$s);
				$s=str_replace("{Contents}",$row_feedback["content"],$s);
				$s=str_replace("{EMail}",$row_feedback["email"],$s);
				echo $s;
				?>
                <?php 
					}
				?>
    </table>
        <table width="100%">
            <tr>
                <td>
                    <?php
                    $qr="SELECT COUNT(contacts_id) from dt_contacts";
                    $result=mysql_query($qr);
                    $row_result=mysql_fetch_array($result);
                    $records=$row_result[0];
                    $total_pages=ceil($records/10);
                    if($total_pages>2){
                        echo "Pages ";
                        for ($i=1; $i<=$total_pages; $i++) {
                            echo "<a href='index.php?p=contactslist&page=".$i."'>".$i."</a> ";
                        }
                    }?>
                </td>
            </tr>
        </table>
    <a href="index.php?p=cpanel" title="Back to Dashboard">&laquo; Back to Dashboard.</a>
	</div>
<?php
//}else{
//unset($_SESSION["IDUser"]);
//unset($_SESSION["Username"]);
//unset($_SESSION["Password"]);
//unset($_SESSION["IDGroup"]);
//header("location:index.php?p=home");
//}
?>